//
//  RootTabBarController.m
//  iNews
//
//  Created by lanou3g on 14-12-4.
//  Copyright (c) 2014年 张在青. All rights reserved.
//

#import "RootTabBarController.h"

#import "NewsRootViewController.h"
#import "RadioRootViewController.h"
#import "videorootViewController.h"
#import "myViewController.h"

#import "CenterTableViewController.h"
#import "LeftTableViewController.h"


@interface RootTabBarController ()

@end

@implementation RootTabBarController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    
    
 
    
    //一键换肤

    [[UITabBar appearance] setBarTintColor:[UIColor colorWithRed:1.000 green:0.097 blue:0.084 alpha:0.450]];
    [[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0.897 green:0.039 blue:0.016 alpha:0.390]];

    [[UITabBar appearance] setBarTintColor:[UIColor colorWithRed:0.7 green:0 blue:0 alpha:0.6]];
    [[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0.7 green:0 blue:0 alpha:0.6]];

 
    
    //创建中间和左视图
    LeftTableViewController *left = [[[LeftTableViewController alloc] initWithStyle:UITableViewStylePlain] autorelease];
    CenterTableViewController *center = [[[CenterTableViewController alloc] initWithStyle:UITableViewStyleGrouped] autorelease];
    NewsRootViewController *newsRVC = [[[NewsRootViewController alloc] initWithCenter:center left:left] autorelease];
    
    UINavigationController *newsNC = [[[UINavigationController alloc] initWithRootViewController:newsRVC] autorelease];
    
    UIImage *nimg = [UIImage imageNamed:@"subscription_topic_new@2x.png"];
    
    UITabBarItem *nitem = [[[UITabBarItem alloc] initWithTitle:@"新闻" image:nimg tag:103] autorelease];
    
     newsNC.tabBarItem = nitem;
    //newsNC.title = @"新闻";
    

    
    RadioRootViewController *radioRVC = [[[RadioRootViewController alloc] init] autorelease];
    UINavigationController *radioNC = [[[UINavigationController alloc] initWithRootViewController:radioRVC] autorelease];
    
    
    UIImage *rimg = [UIImage imageNamed:@"home_header_audio.png"];
    
    UITabBarItem *ritem = [[UITabBarItem alloc] initWithTitle:@"电台" image:rimg tag:104] ;
    
   
    radioRVC.title = @"电台";//初期确认用;
    radioNC.tabBarItem = ritem;
    [ritem release];
    
    
    //初始化videosTableViewController,并被navigation持有
  videorootViewController *videoRVC = [[[videorootViewController alloc]init] autorelease];
    UINavigationController *videoNc = [[[UINavigationController alloc] initWithRootViewController:videoRVC] autorelease];
   UIImage *img = [UIImage imageNamed:@"cell_tag_video_hd@2x.png"];
    
    UITabBarItem *item = [[UITabBarItem alloc] initWithTitle:@"视频" image:img tag:101];
    
    videoNc.tabBarItem = item;
    [item release];


    //初始化collectionsTableViewController,并被navigation持有
   myViewController *collRVC = [[[myViewController alloc] init] autorelease];
    UINavigationController *collNc = [[[UINavigationController alloc] initWithRootViewController:collRVC] autorelease];
    
    UITabBarItem *mitem = [[[UITabBarItem alloc] initWithTabBarSystemItem:  UITabBarSystemItemMore tag:102] autorelease];
    collRVC.tabBarItem = mitem;
    collRVC.title = @"更多";
    
    
    
self.viewControllers = @[newsNC,radioNC,videoNc,collNc];
    
    
    
}

//设置不能横屏
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

-(BOOL)shouldAutorotate
{
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
